package Semantic;

public enum SymbolType 
{
	PARAMS		("params"),
	
	INTEGER		("integer"), 
	REAL		("real"), 
	BOOLEAN		("boolean"), 
	STRING		("string"), 
	RECORDVAR	("recordvar"),

	PROCEDURE	("procedure"), 
	FUNCTION	("function"),
	RECORD		("record"),
	PROGRAM		("program");

	private final String type;

	/**
	 * Constructor of a TypeTag.
	 * 
	 * @param name
	 *            a string with the name of the TypeTag.
	 */
	SymbolType(String type) {
		this.type = type;
	}

	/**
	 * Gets the name of the TypeTag.
	 * 
	 * @return The name of the TypeTag as a string.
	 */
	public String getType() {
		return this.type;
	}

	public static SymbolType fromString(String type) 
	{
		if (type != null) 
		{
			for (SymbolType symbolType : SymbolType.values()) 
			{
				if (type.equalsIgnoreCase(symbolType.type)) 
				{
					return symbolType;
				}
			}
		}
		return null;
	}
}
